# coding=utf-8

import logging
from datetime import datetime

from flask import Blueprint, jsonify, request

bearyRouter = Blueprint(name='beary', import_name=__name__, url_prefix='/beary-chat')
logger = logging.getLogger('')


@bearyRouter.route('/movie', methods=['POST'])
def fetch_movie():
    request_data = request.json
    logger.info('request: {}'.format(request_data))
    now = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
    return jsonify({
        "text": "text, this field may accept markdown",
        "attachments": [
            {
                "title": "title_1_{}".format(now),
                "text": "attachment_text_{}".format(now),
                "color": "#666666",
                "images": [
                    {
                        "url": "http://example.com/index.jpg"
                    },
                    {
                        "url": "http://example.com/index.jpg"
                    }
                ]
            }
        ]
    })
